package com.js.admin.service.impl;

import com.js.admin.entity.BaseTenant;
import com.js.admin.entity.BaseUser;
import com.js.admin.mapper.BaseTenantMapper;
import com.js.admin.mapper.BaseUserMapper;
import com.js.admin.service.BaseTenantService;
import com.js.common.service.impl.BizServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ygl
 * @create 2018-11-06
 * @DESCRIPTION
 **/
@Service
public class BaseTenantServiceImpl extends BizServiceImpl<BaseTenant> implements BaseTenantService {

    @Autowired
    private BaseTenantMapper baseTenantMapper;

    @Autowired
    private BaseUserMapper baseUserMapper;

    @Override
    public void updateUser(String tenantId, String userId) {
        BaseTenant tenant = baseTenantMapper.selectByPrimaryKey(tenantId);
        tenant.setOwner(userId);
        updateSelectiveById(tenant);
        BaseUser user = baseUserMapper.selectByPrimaryKey(userId);
        user.setTenantId(tenantId);
        baseUserMapper.updateByPrimaryKeySelective(user);
    }
}
